#include "config.h"
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <unistd.h>
#include "log.h"
#define BUFSIZE 512
using namespace std;
ostream *_log = NULL;
const char *currentTS(void)
{
	static char buf[BUFSIZE];
	time_t curtime;

	bzero(buf, BUFSIZE);
	curtime = time(NULL);
	strftime(buf, BUFSIZE, "%H:%M:%S", localtime(&curtime));

	return buf;
}
void log_init(const char *filename) {
	if(filename)
		_log = new ofstream(filename);
	else
		_log = &cout;
}
void log_finish() {
	if(_log != &cout) {
		((ofstream*)_log)->close();
		delete _log;
	}
}


